package A002_Obrazek;

import java.awt.Color;
import java.awt.image.BufferedImage;

/**
 * Ustawia srednia filtru
 *
 */
public final class _E_UstawSredniaFiltru2 {
		_C_Filtruj fi; 

	
    	public _E_UstawSredniaFiltru2( BufferedImage _filtr, 
			    			BufferedImage _obrazek, 
			    					boolean _Konwertowac ) throws Exception {
    		 // srednia
    		//int red = 0, redsum = 0, sr_red = 0;
    		//int green = 0, greensum = 0, sr_green = 0;
    		//int blue = 0, bluesum = 0, sr_blue = 0;
			//int tempMax = 0, MinRed = 0, MinGreen = 0,MinBlue = 0;
			//int polowa = 0;
    		//int alpha = 0;
    		//int Fw = (DO.hOb*DO.wOb);
    		if (_Konwertowac == true){
    			fi = new _C_Filtruj (_filtr);
    			fi.UruchomFiltr(10);
    			fi.UruchomFiltr(10);
    		}
			//fi.ConvertGrayscale ();
    		for (int y = 0; y < _obrazek.getHeight(); y++){
    			for (int x = 0; x < _obrazek.getWidth(); x++){
        				int px = _filtr.getRGB (x,y);
        				
    				 	if (px > -16777216) {//-16777216
    				 		_filtr.setRGB(x, y, _obrazek.getRGB (x,y));
    				 		//_obraz2D[x][y]=_obrazek.getRGB (x,y);
				 		} else {
				 			//DO.Filtr.setRGB(x, y, DO.Obrazek.getRGB (x,y));
				 			_filtr.setRGB(x, y, -1);
				 			//DO._obraz2D[x][y]=-1;
				 		}
    			}
    		}
				        		
    	}
}
